﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;

namespace _013_WCFServerDuplex
{
    [ServiceBehavior (InstanceContextMode = InstanceContextMode.PerSession)]
    class Server : IServerInterface
    {

        public void ProcessRequest(int []rq)
        {
            Console.WriteLine("Processing ...");

                int[] resp = new int[rq.Length];

                for(int i=0;i<resp.Length;i++) resp[i] = rq[rq.Length-i-1];
            IServerCallback callback = OperationContext.Current.GetCallbackChannel<IServerCallback>();
            if (callback != null)
                callback.ShowResult(resp);
            else
                Console.WriteLine("No callback found");
        }

    }
}
